package mest.controller.hws;


import mest.entity.plan_productjob_purchase_record;
import mest.service.hws.plan_productjob_purchase_recordService;
import mest.service.system.DBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/plan_productjob_purchase_record")
public class plan_productjob_purchase_recordController {

    @Resource
    private plan_productjob_purchase_recordService pppr;
    @Autowired
    private DBService dbService;

    //新增操作记录表
    @RequestMapping("/insertModel")
    String insert(@RequestBody List<plan_productjob_purchase_record> record, String time1){
        String theirDb = dbService.getCompanyDB();
        System.out.println(record.toString());
//        System.out.println(time1);
        return pppr.insert(theirDb,record,time1);
    };


    //根据id查询记录表
    @RequestMapping("/selectById")
    String selectByPrimaryKey(Integer id){
        String theirDb = dbService.getCompanyDB();
        return pppr.selectByPrimaryKey(theirDb,id);
    };

    //根据pppid查询全部记录表
    @RequestMapping("/selectAll")
    Map<String, Object> selectPrimary(Integer pppId, Integer limit, Integer page){
        String theirDb = dbService.getCompanyDB();
        return pppr.selectPrimary(theirDb,pppId, limit, page);
    };


    //更新记录表
    @RequestMapping("/updateByone")
    String updateByPrimaryKey(plan_productjob_purchase_record record){
        String theirDb = dbService.getCompanyDB();
        return pppr.updateByPrimaryKey(theirDb,record);
    };
}
